<?php
require $_SERVER['DOCUMENT_ROOT'].'/../_core/common.php';

$msg = array();

//权限验证
if( Role::init() == false ){
	$msg['error'] = false;
	$msg['string'] = '权限不足！';
	$myjson = json_encode($msg); 
	echo $myjson; 
	exit;
}

$db = new DB();

$id = isset($_POST['id']) ? h($_POST['id']) : '';

$group_sql = 'select id,name from users_group where id='.$id.' limit 1';
$group_rs = $db->query($group_sql)->getOne();

if( $group_rs['id'] < 2 ){//id不存在
	$msg['error'] = false;
	$msg['string'] = '参数有误！';
}else{
	//更新is_del字段
	$data=array('is_del'=>2,'updated'=>time());
	$db->table('users_group')->where('id='.$id)->update($data)->run();
	
	$msg['error'] = true;
	$msg['string'] = '成功删除职务 '.$group_rs['name'].' !';
}
$myjson = json_encode($msg); 
echo $myjson; 
exit;